package be.ipl.diavoloz.daoimpl;

import java.util.Iterator;
import java.util.List;

import javax.ejb.Stateless;

import be.ipl.diavoloz.dao.DeDao;
import be.ipl.diavoloz.modele.De;

@SuppressWarnings("serial")
@Stateless
public class DeDaoImpl extends DaoImpl<Integer, De> implements DeDao{

	@Override
	public De getDe(int id) {
		String queryString = "SELECT d from De d where d.id = ?1";
		return recherche(queryString, id);
	}
	
	@Override
	public List<De> getListeDe(int idTour) {
		String queryString = "SELECT d from De d where d.de_tour = ?1";
		return liste(queryString, idTour);
	}

	@Override
	public void supprimerTable() {
		String queryString = "SELECT d from De";
		List<De> l = liste(queryString, null);
		Iterator<De> it = l.iterator();
		while(it.hasNext()){
			De d = (De) it.next();
			supprimer(d.getId());
		}	
	}
	
}
